package com.movie.modules.jf.controller;

import java.util.Arrays;
import java.util.Map;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.movie.modules.jf.entity.ActorEntity;
import com.movie.modules.jf.service.ActorService;
import com.movie.common.utils.PageUtils;
import com.movie.common.utils.R;



/**
 * 演员表
 *
 * @author kakarot
 * @email 532050892@qq.com
 * @date 2021-08-20 01:31:10
 */
@RestController
@RequestMapping("/sys/actor")
@Api(tags = "后台电影模块")
public class ActorController {
    @Autowired
    private ActorService actorService;

    /**
     * 列表
     */
    @GetMapping("/list")
    @ApiOperation("演员分页查询")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = actorService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{actorId}")
    @ApiOperation("演员详情")
    public R info(@PathVariable("actorId") Integer actorId){
        return R.ok().put("data", actorService.getInfoById(actorId));
    }

    /**
     * 保存
     */
    @PostMapping("/update")
    @ApiOperation("添加/修改演员")
    public R update(@RequestBody ActorEntity actor){
		actorService.update(actor);
        return R.ok();
    }

    @PostMapping("/status")
    @ApiOperation("更改演员状态")
    public R status(@RequestBody ActorEntity actor){
        actorService.updateById(actor);
        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete/{actorId}")
    @ApiOperation("删除演员信息")
    public R delete(@PathVariable("actorId") Integer actorId){
        actorService.delete(actorId);
        return R.ok();
    }

    @GetMapping("/select")
    @ApiOperation("演员下拉框")
    public R select(){
        return R.ok().put("data",actorService.getSelect());
    }
}
